package com.tac.controller.wms;


import com.github.pagehelper.PageInfo;
import com.tac.common.result.Result;
import com.tac.pojo.wms.MaterialInventory;
import com.tac.service.wms.MaterialInventoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/materialInventory")
@Api(tags = "智能仓储WMS--物料库存")
@CrossOrigin
public class MaterialInventoryController {

    @Autowired
    private MaterialInventoryService materialInventoryService;

    @GetMapping("/getList")
    @ApiOperation("物料库存接口列表查看")
    public Result<PageInfo<MaterialInventory>> getList(@RequestParam(required = false) String name,
                                                   @RequestParam(required = false) String model,
                                                   @RequestParam(required = false) String specifications,
                                                   @RequestParam(defaultValue = "1") Integer pageNum,
                                                   @RequestParam(defaultValue = "10") Integer pageSize) {
        return materialInventoryService.getList(pageNum, pageSize, name, model, specifications);
    }

    @PostMapping("/save")
    @ApiOperation("物料库存添加")
    public Result save(@RequestBody MaterialInventory materialInventory) {
        return materialInventoryService.save(materialInventory);
    }

    @DeleteMapping("/remove")
    @ApiOperation("物料库存删除")
    public Result remove(@RequestBody List<Integer> ids) {
        return materialInventoryService.remove(ids);
    }

    @PutMapping("/update")
    @ApiOperation("物料库存修改")
    public Result update(@RequestBody MaterialInventory materialInventory) {
        return materialInventoryService.update(materialInventory);
    }
}
